<?php

namespace App\Http\Controllers\Api\V1\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class VideoResource extends JsonResource
{
	public function toArray($request)
	{
		$resource = $this->resource;
		
		return [
			'id'                => (int)$resource->id,
			'video_url'             =>  $resource->video_url ? img_path($resource->video_url) : '',
			'title_cn'              =>$resource->title ?? '',
			'title_en'              =>$resource->title_en ? explode("#",$resource->title_en)[0] :  '',
			'brief_en'              =>$resource->brief_en ?? '',
			'url' =>$resource->url ?? '',
			'source' =>$resource->blogger ? $resource->blogger->blogger_url_type :  '',
			'created_at' => (string)$resource->created_at ?? '',
			
		];
	}
}
